package com.pac.hospital.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pac.hospital.bean.HospitalBean;
import com.pac.hospital.dao.HospitalDao;

/**
 * 医院dao实现
 * 
 * @author lujun.chen
 * @version [版本号, 2015年2月14日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Repository(value = "hospitalDao")
public class HospitalDaoImpl implements HospitalDao {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public String addHospital(HospitalBean hospitalBean) {
		sqlSessionTemplate.insert("addHospital", hospitalBean);
		return hospitalBean.getId();
	}

	@Override
	public boolean updateHospital(HospitalBean hospitalBean) {
		int n = sqlSessionTemplate.update("updateHospital", hospitalBean);
		return n > 0;
	}

	@Override
	public boolean delHospital(HospitalBean hospitalBean) {
		int n = sqlSessionTemplate.delete("delHospital", hospitalBean);
		return n > 0;
	}

	@Override
	public List<HospitalBean> queryHospital(HospitalBean hospitalBean) {

		return sqlSessionTemplate.selectList("queryHospital", hospitalBean);
	}

}
